package cn.mhome.merchant.framework.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 主页跳转
 * @author lvpeng
 */
@Controller
@RequestMapping("/view/main")
public class HomeController {

	
	@RequestMapping(value = "/index")
	public String index(HttpServletRequest req, Model model){
		if (SecurityUtils.getSubject().isAuthenticated() == false) {
			return "redirect:/view/main/login";
		}
		return "index";
	}

	@RequestMapping(value = "/login")
	public String login(HttpServletRequest req, HttpServletResponse resp, Model model){
		if (SecurityUtils.getSubject().isAuthenticated()) {
			return "redirect:/view/main/index";
		}
		return "login";
	}
}
